Date: The date during which each data point was recorded
BTC: Closing stock price for Bitcoin
BNB: Closing stock price for Binance Coin
ETH: Closing stock price for Ether
XRP: Closing stock price for XRP
DOGE: Closing stock price for Dogecoin
library(zoo)
library(lubridate)
library(mgcv)
library(TSA)
library(xts)
library(vars)
library(rugarch)
library(aod)
library(car)
To read the data in R, save the file in your working
directory (make sure you have changed the directory if different from
the R working directory) and read the data using the R
function read.csv()
#Read in data
#create data frame with 0 rows and 3 columns
data <- data.frame(matrix(ncol = 6, nrow = 1240))
#provide column names
colnames(data) <- c('Date','BTC', 'BNB', 'ETH','XRP','DOGE')
data[,1] <-read.csv("BTC.csv", head = TRUE)$Date
data[,2] <-read.csv("BTC.csv", head = TRUE)$Close
data[,3] <-read.csv("BNB.csv", head = TRUE)$Close
data[,4] <-read.csv("ETH.csv", head = TRUE)$Close
data[,5] <-read.csv("XRP.csv", head = TRUE)$Close
data[,6] <-read.csv("DOGE.csv", head = TRUE)$Close
for (i in 2:6){
data[,i] <- log(data[,i])
}
data$Date<-as.Date(data$Date)
data.train<-data[1:(nrow(data)-14),]
data.test<-data[(nrow(data)-13):nrow(data),]
#Convert stock data to Time Series
btc.ts<-ts(data$BTC)
bnb.ts<-ts(data$BNB)
eth.ts<-ts(data$ETH)
xrp.ts<-ts(data$XRP)
doge.ts<-ts(data$DOGE)
btc.ts.train<-ts(data.train$BTC)
bnb.ts.train<-ts(data.train$BNB)
eth.ts.train<-ts(data.train$ETH)
xrp.ts.train<-ts(data.train$XRP)
doge.ts.train<-ts(data.train$DOGE)
btc.ts.test<-ts(data.test$BTC)
bnb.ts.test<-ts(data.test$BNB)
eth.ts.test<-ts(data.test$ETH)
xrp.ts.test<-ts(data.test$XRP)
doge.ts.test<-ts(data.test$DOGE)
#Initialize plot colors
btc.col<-"#FF8C00"
bnb.col<-"#008000"
eth.col<-"#20B2AA"
xrp.col<-"#1E90FF"
doge.col<-"#9932CC"
#Plot each Time Series
plot(ts(data[,2:6]), main = "Price")
plot(data$Date,btc.ts,main="BTC",xlab="Time",ylab="Price",col=btc.col,type = "l")
plot(data$Date,bnb.ts,main="BNB",xlab="Time",ylab="Price",col=bnb.col,type = "l")
plot(data$Date,eth.ts,main="ETH",xlab="Time",ylab="Price",col=eth.col,type = "l")
plot(data$Date,xrp.ts,main="XRP",xlab="Time",ylab="Price",col=xrp.col,type = "l")
plot(data$Date,doge.ts,main="DOGE",xlab="Time",ylab="Price",col=doge.col,type = "l")
** BTC **
# Final model for BTC
spec.btc = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
include.mean=T),
distribution.model="std")
fit.btc = ugarchfit(spec.btc, btc.ts.train, solver = 'hybrid')
# Final model for BTC
spec.btc1 = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
arfima=T),
fixed.pars=list(arfima=1),
distribution.model="std")
fit.btc1 = ugarchfit(spec.btc1, btc.ts.train, solver = 'hybrid')
** BNB **
# Final model for BNB
spec.bnb = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
include.mean=T),
distribution.model="std")
fit.bnb = ugarchfit(spec.bnb, bnb.ts.train, solver = 'hybrid')
# Final model for BTC
spec.bnb1 = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
arfima=T),
fixed.pars=list(arfima=1),
distribution.model="std")
fit.bnb1 = ugarchfit(spec.bnb1, bnb.ts.train, solver = 'hybrid')
** ETH **
# Final model for ETH
spec.eth = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
include.mean=T),
distribution.model="std")
fit.eth = ugarchfit(spec.eth, eth.ts.train, solver = 'hybrid')
# Final model for BTC
spec.eth1 = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
arfima=T),
fixed.pars=list(arfima=1),
distribution.model="std")
fit.eth1 = ugarchfit(spec.eth1, eth.ts.train, solver = 'hybrid')
** XRP **
# Final model for XRP
spec.xrp = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
include.mean=T),
distribution.model="std")
fit.xrp = ugarchfit(spec.xrp, xrp.ts.train, solver = 'hybrid')
# Final model for BTC
spec.xrp1 = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
arfima=T),
fixed.pars=list(arfima=1),
distribution.model="std")
fit.xrp1 = ugarchfit(spec.xrp1, xrp.ts.train, solver = 'hybrid')
** DOGE **
# Final model for DOGE
spec.doge = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
include.mean=T),
distribution.model="std")
fit.doge = ugarchfit(spec.doge, doge.ts.train, solver = 'hybrid')
# Final model for BTC
spec.doge1 = ugarchspec(variance.model=list(garchOrder=c(1,1)),
mean.model=list(armaOrder=c(1,1),
arfima=T),
fixed.pars=list(arfima=1),
distribution.model="std")
fit.doge1 = ugarchfit(spec.doge1, doge.ts.train, solver = 'hybrid')
** Model Summary ***
fit.btc
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 9.133186 0.027219 335.54079 0.00000
## ar1 0.999999 0.000573 1743.74828 0.00000
## ma1 -0.037163 0.024323 -1.52791 0.12654
## omega 0.000007 0.000012 0.60954 0.54217
## alpha1 0.052530 0.002302 22.81810 0.00000
## beta1 0.946469 0.020975 45.12448 0.00000
## shape 3.188435 0.203962 15.63253 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 9.133186 0.001759 5192.31636 0.000000
## ar1 0.999999 0.000559 1788.02362 0.000000
## ma1 -0.037163 0.026177 -1.41969 0.155699
## omega 0.000007 0.000029 0.25359 0.799815
## alpha1 0.052530 0.028920 1.81639 0.069311
## beta1 0.946469 0.056034 16.89106 0.000000
## shape 3.188435 0.432509 7.37195 0.000000
##
## LogLikelihood : 2608.916
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.2446
## Bayes -4.2154
## Shibata -4.2446
## Hannan-Quinn -4.2336
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 7.125 7.601e-03
## Lag[2*(p+q)+(p+q)-1][5] 9.395 8.077e-12
## Lag[4*(p+q)+(p+q)-1][9] 11.278 2.510e-03
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 8.130 0.004353
## Lag[2*(p+q)+(p+q)-1][5] 9.555 0.011966
## Lag[4*(p+q)+(p+q)-1][9] 10.422 0.040701
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 1.875 0.500 2.000 0.1709
## ARCH Lag[5] 2.364 1.440 1.667 0.3963
## ARCH Lag[7] 2.667 2.315 1.543 0.5784
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 5.0052
## Individual Statistics:
## mu 0.0006267
## ar1 0.1545689
## ma1 0.0451198
## omega 1.1433820
## alpha1 3.1625870
## beta1 2.6018107
## shape 1.8612704
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.7196 0.085756 *
## Negative Sign Bias 2.9381 0.003364 ***
## Positive Sign Bias 0.8943 0.371328
## Joint Effect 9.4399 0.023980 **
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 30.80 0.04243
## 2 30 43.15 0.04408
## 3 40 47.21 0.17206
## 4 50 57.28 0.19493
##
##
## Elapsed time : 0.7155681
fit.btc1
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,d,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 9.132136 0.026810 340.6220 0.00000
## ar1 0.986251 0.003583 275.2594 0.00000
## ma1 -0.983117 0.000478 -2057.5768 0.00000
## arfima 1.000000 NA NA NA
## omega 0.000008 0.000013 0.5875 0.55687
## alpha1 0.053926 0.003168 17.0214 0.00000
## beta1 0.945074 0.021919 43.1160 0.00000
## shape 3.206431 0.201508 15.9122 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 9.132136 0.005287 1727.1957 0.000000
## ar1 0.986251 0.003773 261.4107 0.000000
## ma1 -0.983117 0.000580 -1694.1791 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000008 0.000034 0.2289 0.818943
## alpha1 0.053926 0.028140 1.9164 0.055319
## beta1 0.945074 0.061775 15.2986 0.000000
## shape 3.206431 0.452955 7.0789 0.000000
##
## LogLikelihood : 2608.141
##
## Information Criteria
## ------------------------------------
##
## Akaike -4.2433
## Bayes -4.2141
## Shibata -4.2434
## Hannan-Quinn -4.2323
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.867 0.1718
## Lag[2*(p+q)+(p+q)-1][5] 3.442 0.2307
## Lag[4*(p+q)+(p+q)-1][9] 5.131 0.4245
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 6.906 0.008593
## Lag[2*(p+q)+(p+q)-1][5] 8.433 0.022991
## Lag[4*(p+q)+(p+q)-1][9] 9.321 0.069758
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 2.064 0.500 2.000 0.1508
## ARCH Lag[5] 2.622 1.440 1.667 0.3495
## ARCH Lag[7] 2.894 2.315 1.543 0.5338
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 4.9028
## Individual Statistics:
## mu 0.02488
## ar1 0.38206
## ma1 0.38607
## omega 1.15651
## alpha1 3.03399
## beta1 2.49512
## shape 1.80590
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.6336 0.102600
## Negative Sign Bias 2.8622 0.004278 ***
## Positive Sign Bias 0.9476 0.343496
## Joint Effect 9.1353 0.027545 **
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 26.59 0.11448
## 2 30 46.58 0.02054
## 3 40 50.67 0.09979
## 4 50 71.23 0.02069
##
##
## Elapsed time : 2.508583
fit.bnb
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 2.822013 0.029199 96.6478 0.000000
## ar1 1.000000 0.000319 3135.3557 0.000000
## ma1 -0.099023 0.027531 -3.5967 0.000322
## omega 0.000040 0.000020 2.0202 0.043360
## alpha1 0.164289 0.038550 4.2617 0.000020
## beta1 0.834711 0.038468 21.6987 0.000000
## shape 3.715059 0.378671 9.8108 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 2.822013 0.001165 2423.1247 0.000000
## ar1 1.000000 0.000414 2413.2163 0.000000
## ma1 -0.099023 0.024783 -3.9957 0.000065
## omega 0.000040 0.000031 1.2737 0.202786
## alpha1 0.164289 0.047954 3.4260 0.000613
## beta1 0.834711 0.057003 14.6433 0.000000
## shape 3.715059 0.342357 10.8514 0.000000
##
## LogLikelihood : 2360.224
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.8389
## Bayes -3.8097
## Shibata -3.8389
## Hannan-Quinn -3.8279
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 4.491 3.407e-02
## Lag[2*(p+q)+(p+q)-1][5] 9.649 2.104e-12
## Lag[4*(p+q)+(p+q)-1][9] 12.410 7.422e-04
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.456 0.4995
## Lag[2*(p+q)+(p+q)-1][5] 2.153 0.5828
## Lag[4*(p+q)+(p+q)-1][9] 3.191 0.7270
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.6639 0.500 2.000 0.4152
## ARCH Lag[5] 0.8429 1.440 1.667 0.7801
## ARCH Lag[7] 1.6981 2.315 1.543 0.7808
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 3.3769
## Individual Statistics:
## mu 0.0003852
## ar1 0.3607008
## ma1 0.0467525
## omega 2.1887990
## alpha1 2.3420059
## beta1 2.2221078
## shape 1.8425209
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 2.0838 0.03738 **
## Negative Sign Bias 1.0988 0.27208
## Positive Sign Bias 0.6201 0.53531
## Joint Effect 4.4133 0.22016
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 22.87 0.2429
## 2 30 29.79 0.4245
## 3 40 39.91 0.4297
## 4 50 51.90 0.3617
##
##
## Elapsed time : 0.4297361
fit.bnb1
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,d,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 2.818506 0.031149 90.4835 0.000000
## ar1 0.998250 0.002108 473.6476 0.000000
## ma1 -0.996522 0.000267 -3732.0553 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000044 0.000021 2.1374 0.032566
## alpha1 0.177676 0.038373 4.6302 0.000004
## beta1 0.821324 0.036740 22.3553 0.000000
## shape 3.836933 0.421431 9.1045 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 2.818506 0.013398 210.3742 0.00000
## ar1 0.998250 0.003835 260.3031 0.00000
## ma1 -0.996522 0.000381 -2617.3235 0.00000
## arfima 1.000000 NA NA NA
## omega 0.000044 0.000032 1.3587 0.17424
## alpha1 0.177676 0.050805 3.4972 0.00047
## beta1 0.821324 0.058218 14.1077 0.00000
## shape 3.836933 0.448223 8.5603 0.00000
##
## LogLikelihood : 2354.822
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.8301
## Bayes -3.8009
## Shibata -3.8301
## Hannan-Quinn -3.8191
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.4475 0.50352
## Lag[2*(p+q)+(p+q)-1][5] 4.3542 0.02547
## Lag[4*(p+q)+(p+q)-1][9] 6.9943 0.12857
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.4804 0.4882
## Lag[2*(p+q)+(p+q)-1][5] 2.0694 0.6021
## Lag[4*(p+q)+(p+q)-1][9] 3.0912 0.7438
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.8242 0.500 2.000 0.3640
## ARCH Lag[5] 0.9461 1.440 1.667 0.7490
## ARCH Lag[7] 1.7853 2.315 1.543 0.7626
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 3.1688
## Individual Statistics:
## mu 0.03096
## ar1 0.11857
## ma1 0.13275
## omega 2.24400
## alpha1 2.25431
## beta1 2.22182
## shape 1.80336
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 2.2776 0.02292 **
## Negative Sign Bias 1.2892 0.19757
## Positive Sign Bias 0.5668 0.57099
## Joint Effect 5.3970 0.14493
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 13.80 0.7950
## 2 30 28.81 0.4749
## 3 40 36.58 0.5809
## 4 50 51.65 0.3706
##
##
## Elapsed time : 2.184696
fit.eth
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 5.478294 0.029897 183.23712 0.000000
## ar1 1.000000 0.000448 2233.66734 0.000000
## ma1 -0.056744 0.027231 -2.08380 0.037178
## omega 0.000012 0.000012 0.98983 0.322259
## alpha1 0.075269 0.019912 3.78003 0.000157
## beta1 0.923730 0.024810 37.23180 0.000000
## shape 4.104243 0.515560 7.96074 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 5.478294 0.001288 4252.15538 0.000000
## ar1 1.000000 0.000504 1983.87836 0.000000
## ma1 -0.056744 0.028022 -2.02500 0.042868
## omega 0.000012 0.000024 0.48861 0.625116
## alpha1 0.075269 0.033581 2.24139 0.025000
## beta1 0.923730 0.049591 18.62690 0.000000
## shape 4.104243 0.709730 5.78283 0.000000
##
## LogLikelihood : 2270.628
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.6927
## Bayes -3.6635
## Shibata -3.6928
## Hannan-Quinn -3.6817
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 4.288 3.839e-02
## Lag[2*(p+q)+(p+q)-1][5] 9.488 4.933e-12
## Lag[4*(p+q)+(p+q)-1][9] 12.332 8.086e-04
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 1.019 0.3129
## Lag[2*(p+q)+(p+q)-1][5] 1.895 0.6435
## Lag[4*(p+q)+(p+q)-1][9] 2.464 0.8431
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.7484 0.500 2.000 0.3870
## ARCH Lag[5] 1.0261 1.440 1.667 0.7252
## ARCH Lag[7] 1.0759 2.315 1.543 0.9009
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 3.5901
## Individual Statistics:
## mu 0.0004088
## ar1 0.6162578
## ma1 0.1823773
## omega 1.1588791
## alpha1 2.2816869
## beta1 1.8339381
## shape 2.0482578
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.9293 0.3529
## Negative Sign Bias 0.8414 0.4003
## Positive Sign Bias 1.0130 0.3113
## Joint Effect 1.7346 0.6293
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 23.46 0.2176
## 2 30 23.53 0.7519
## 3 40 37.88 0.5207
## 4 50 41.46 0.7694
##
##
## Elapsed time : 0.267648
fit.eth1
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,d,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu 5.475611 0.025542 214.3726 0.00000
## ar1 0.999018 0.002640 378.3853 0.00000
## ma1 -0.996812 0.000311 -3209.1981 0.00000
## arfima 1.000000 NA NA NA
## omega 0.000014 0.000010 1.3695 0.17083
## alpha1 0.081930 0.007319 11.1936 0.00000
## beta1 0.917070 0.011128 82.4131 0.00000
## shape 4.128350 0.437180 9.4431 0.00000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 5.475611 0.039652 138.09073 0.000000
## ar1 0.999018 0.006491 153.90727 0.000000
## ma1 -0.996812 0.000802 -1242.66101 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000014 0.000018 0.79231 0.428182
## alpha1 0.081930 0.039490 2.07469 0.038015
## beta1 0.917070 0.045615 20.10455 0.000000
## shape 4.128350 0.678306 6.08626 0.000000
##
## LogLikelihood : 2269.42
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.6907
## Bayes -3.6615
## Shibata -3.6908
## Hannan-Quinn -3.6798
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.05864 0.808652
## Lag[2*(p+q)+(p+q)-1][5] 4.68622 0.009315
## Lag[4*(p+q)+(p+q)-1][9] 7.57470 0.081883
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.5225 0.4698
## Lag[2*(p+q)+(p+q)-1][5] 1.3910 0.7667
## Lag[4*(p+q)+(p+q)-1][9] 1.9458 0.9114
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.7964 0.500 2.000 0.3722
## ARCH Lag[5] 1.0570 1.440 1.667 0.7161
## ARCH Lag[7] 1.1243 2.315 1.543 0.8925
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 3.3206
## Individual Statistics:
## mu 0.04868
## ar1 0.32104
## ma1 0.45035
## omega 1.27205
## alpha1 2.12301
## beta1 1.73444
## shape 1.95507
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.9666 0.3340
## Negative Sign Bias 0.6861 0.4928
## Positive Sign Bias 1.1162 0.2645
## Joint Effect 1.7260 0.6312
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 18.14 0.5129
## 2 30 31.16 0.3579
## 3 40 31.68 0.7910
## 4 50 42.52 0.7318
##
##
## Elapsed time : 1.758789
fit.xrp
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -1.683007 0.028820 -58.3966 0.000000
## ar1 0.999081 0.000785 1273.2796 0.000000
## ma1 -0.104048 0.027761 -3.7480 0.000178
## omega 0.000194 0.000059 3.2930 0.000991
## alpha1 0.232447 0.058395 3.9806 0.000069
## beta1 0.766553 0.043772 17.5123 0.000000
## shape 2.869126 0.238840 12.0128 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -1.683007 0.003209 -524.4806 0.000000
## ar1 0.999081 0.000814 1227.2807 0.000000
## ma1 -0.104048 0.025832 -4.0279 0.000056
## omega 0.000194 0.000078 2.4804 0.013123
## alpha1 0.232447 0.069746 3.3327 0.000860
## beta1 0.766553 0.067776 11.3102 0.000000
## shape 2.869126 0.219914 13.0466 0.000000
##
## LogLikelihood : 2159.779
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.5119
## Bayes -3.4827
## Shibata -3.5119
## Hannan-Quinn -3.5009
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 3.909 4.804e-02
## Lag[2*(p+q)+(p+q)-1][5] 5.989 8.154e-05
## Lag[4*(p+q)+(p+q)-1][9] 7.252 1.056e-01
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.01122 0.9156
## Lag[2*(p+q)+(p+q)-1][5] 0.08610 0.9986
## Lag[4*(p+q)+(p+q)-1][9] 0.17988 1.0000
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.04026 0.500 2.000 0.8410
## ARCH Lag[5] 0.11315 1.440 1.667 0.9843
## ARCH Lag[7] 0.16978 2.315 1.543 0.9979
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 2.8692
## Individual Statistics:
## mu 0.003255
## ar1 0.031345
## ma1 0.156874
## omega 1.051398
## alpha1 1.859553
## beta1 2.191060
## shape 1.326861
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 1.0174 0.3092
## Negative Sign Bias 0.4587 0.6465
## Positive Sign Bias 0.4480 0.6542
## Joint Effect 1.0386 0.7919
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 15.79 0.6709
## 2 30 32.29 0.3074
## 3 40 32.01 0.7787
## 4 50 48.55 0.4912
##
##
## Elapsed time : 0.2041841
fit.xrp1
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,d,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -1.685929 0.029209 -57.7195 0.000000
## ar1 0.956442 0.006698 142.7866 0.000000
## ma1 -0.969850 0.002399 -404.3062 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000191 0.000056 3.3833 0.000716
## alpha1 0.236594 0.058366 4.0536 0.000050
## beta1 0.762406 0.042200 18.0665 0.000000
## shape 2.925283 0.249253 11.7362 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -1.685929 0.003561 -473.4051 0.000000
## ar1 0.956442 0.006723 142.2744 0.000000
## ma1 -0.969850 0.000624 -1554.9534 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000191 0.000061 3.1096 0.001873
## alpha1 0.236594 0.062464 3.7877 0.000152
## beta1 0.762406 0.049728 15.3316 0.000000
## shape 2.925283 0.255635 11.4432 0.000000
##
## LogLikelihood : 2154.474
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.5032
## Bayes -3.4740
## Shibata -3.5033
## Hannan-Quinn -3.4922
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.01281 0.9099
## Lag[2*(p+q)+(p+q)-1][5] 2.47671 0.7909
## Lag[4*(p+q)+(p+q)-1][9] 4.09946 0.6676
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.01419 0.9052
## Lag[2*(p+q)+(p+q)-1][5] 0.08642 0.9986
## Lag[4*(p+q)+(p+q)-1][9] 0.17481 1.0000
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.0406 0.500 2.000 0.8403
## ARCH Lag[5] 0.1135 1.440 1.667 0.9843
## ARCH Lag[7] 0.1647 2.315 1.543 0.9981
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 2.9229
## Individual Statistics:
## mu 0.009117
## ar1 0.114124
## ma1 0.119628
## omega 1.053408
## alpha1 1.710450
## beta1 2.213592
## shape 1.255311
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.9374 0.3487
## Negative Sign Bias 0.4500 0.6528
## Positive Sign Bias 0.3286 0.7425
## Joint Effect 0.8810 0.8300
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 11.88 0.8907
## 2 30 21.81 0.8278
## 3 40 39.19 0.4615
## 4 50 43.17 0.7075
##
##
## Elapsed time : 2.18996
fit.doge
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,0,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -5.776771 0.047855 -120.7149 0.000000
## ar1 0.999523 0.000297 3368.4669 0.000000
## ma1 -0.154861 0.027482 -5.6349 0.000000
## omega 0.000315 0.000127 2.4813 0.013091
## alpha1 0.326790 0.079929 4.0885 0.000043
## beta1 0.672210 0.084268 7.9771 0.000000
## shape 2.712473 0.166661 16.2754 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -5.776771 0.002432 -2375.0324 0.000000
## ar1 0.999523 0.000370 2703.7462 0.000000
## ma1 -0.154861 0.028361 -5.4603 0.000000
## omega 0.000315 0.000301 1.0464 0.295368
## alpha1 0.326790 0.133435 2.4491 0.014323
## beta1 0.672210 0.195700 3.4349 0.000593
## shape 2.712473 0.178402 15.2043 0.000000
##
## LogLikelihood : 2091.299
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.4002
## Bayes -3.3710
## Shibata -3.4002
## Hannan-Quinn -3.3892
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 3.045 0.080965
## Lag[2*(p+q)+(p+q)-1][5] 5.018 0.003116
## Lag[4*(p+q)+(p+q)-1][9] 6.100 0.240560
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.05201 0.8196
## Lag[2*(p+q)+(p+q)-1][5] 0.10055 0.9981
## Lag[4*(p+q)+(p+q)-1][9] 0.18633 0.9999
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.01692 0.500 2.000 0.8965
## ARCH Lag[5] 0.07200 1.440 1.667 0.9917
## ARCH Lag[7] 0.13687 2.315 1.543 0.9987
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 5.9044
## Individual Statistics:
## mu 0.01536
## ar1 0.17591
## ma1 0.04450
## omega 1.05983
## alpha1 1.34532
## beta1 1.02318
## shape 0.72626
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.3342 0.7383
## Negative Sign Bias 1.6046 0.1088
## Positive Sign Bias 0.1400 0.8886
## Joint Effect 4.1130 0.2495
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 22.71 0.2503
## 2 30 29.01 0.4646
## 3 40 37.43 0.5418
## 4 50 49.04 0.4715
##
##
## Elapsed time : 0.363719
fit.doge1
##
## *---------------------------------*
## * GARCH Model Fit *
## *---------------------------------*
##
## Conditional Variance Dynamics
## -----------------------------------
## GARCH Model : sGARCH(1,1)
## Mean Model : ARFIMA(1,d,1)
## Distribution : std
##
## Optimal Parameters
## ------------------------------------
## Estimate Std. Error t value Pr(>|t|)
## mu -5.779988 0.057476 -100.5634 0.000000
## ar1 0.995200 0.000975 1020.7173 0.000000
## ma1 -0.997360 0.000185 -5391.9276 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000359 0.000125 2.8669 0.004145
## alpha1 0.394547 0.083050 4.7507 0.000002
## beta1 0.604453 0.076942 7.8560 0.000000
## shape 2.855502 0.187618 15.2198 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu -5.779988 0.010150 -569.4579 0.000000
## ar1 0.995200 0.001189 836.8110 0.000000
## ma1 -0.997360 0.000123 -8077.6069 0.000000
## arfima 1.000000 NA NA NA
## omega 0.000359 0.000231 1.5534 0.120317
## alpha1 0.394547 0.110925 3.5569 0.000375
## beta1 0.604453 0.150565 4.0146 0.000060
## shape 2.855502 0.176362 16.1912 0.000000
##
## LogLikelihood : 2078.775
##
## Information Criteria
## ------------------------------------
##
## Akaike -3.3797
## Bayes -3.3505
## Shibata -3.3798
## Hannan-Quinn -3.3687
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.6861 0.4075
## Lag[2*(p+q)+(p+q)-1][5] 1.9295 0.9698
## Lag[4*(p+q)+(p+q)-1][9] 3.0758 0.8788
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 0.03134 0.8595
## Lag[2*(p+q)+(p+q)-1][5] 0.09109 0.9984
## Lag[4*(p+q)+(p+q)-1][9] 0.20227 0.9999
## d.o.f=2
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[3] 0.02151 0.500 2.000 0.8834
## ARCH Lag[5] 0.08281 1.440 1.667 0.9899
## ARCH Lag[7] 0.17673 2.315 1.543 0.9978
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 5.2952
## Individual Statistics:
## mu 0.02818
## ar1 0.06691
## ma1 0.06350
## omega 1.15412
## alpha1 1.45641
## beta1 1.11442
## shape 0.71722
##
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic: 1.69 1.9 2.35
## Individual Statistic: 0.35 0.47 0.75
##
## Sign Bias Test
## ------------------------------------
## t-value prob sig
## Sign Bias 0.3766 0.7065
## Negative Sign Bias 1.2952 0.1955
## Positive Sign Bias 0.0149 0.9881
## Joint Effect 3.0569 0.3829
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 23.14 0.2314
## 2 30 33.27 0.2671
## 3 40 47.74 0.1592
## 4 50 52.63 0.3354
##
##
## Elapsed time : 2.135144
layout(mat = matrix(c(1,1,2,2,3,3,
0,4,4,5,5,0), nrow = 2, byrow = TRUE))
ts.plot(btc.ts.train,ylab="Log Price",col="black")
lines(fit.btc@fit$fitted.values,col=btc.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",btc.col),cex=0.7)
ts.plot(bnb.ts.train,ylab="Log Price",col="black")
lines(fit.bnb@fit$fitted.values,col=bnb.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",bnb.col),cex=0.7)
ts.plot(eth.ts.train,ylab="Log Price",col="black")
lines(fit.eth@fit$fitted.values,col=eth.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",eth.col),cex=0.7)
ts.plot(xrp.ts.train,ylab="Log Price",col="black")
lines(fit.xrp@fit$fitted.values,col=xrp.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",xrp.col),cex=0.7)
ts.plot(doge.ts.train,ylab="Log Price",col="black")
lines(fit.doge@fit$fitted.values,col=doge.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",doge.col),cex=0.7)
layout(mat = matrix(c(1,1,2,2,3,3,
0,4,4,5,5,0), nrow = 2, byrow = TRUE))
ts.plot(btc.ts.train,ylab="Log Price",col="black")
lines(fit.btc1@fit$fitted.values,col=btc.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",btc.col),cex=0.7)
ts.plot(bnb.ts.train,ylab="Log Price",col="black")
lines(fit.bnb1@fit$fitted.values,col=bnb.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",bnb.col),cex=0.7)
ts.plot(eth.ts.train,ylab="Log Price",col="black")
lines(fit.eth1@fit$fitted.values,col=eth.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",eth.col),cex=0.7)
ts.plot(xrp.ts.train,ylab="Log Price",col="black")
lines(fit.xrp1@fit$fitted.values,col=xrp.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",xrp.col),cex=0.7)
ts.plot(doge.ts.train,ylab="Log Price",col="black")
lines(fit.doge1@fit$fitted.values,col=doge.col)
legend(x="topleft",legend=c("Log Price","Fitted values"), lty=1,col=c("black",doge.col),cex=0.7)
** Residuals **
#qqPlot(x=ugarcg.resid,distribution="t",df=4.797230)
par(mfrow=c(2,2))
ts.plot(residuals(fit.btc), main = "Residuals")
ts.plot(ts(fit.btc@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.btc)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.btc)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.btc@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.btc@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.btc@fit$z,distribution="t",df=tail(fit.btc@fit$coef,1))
## [1] 856 707
#qqPlot(x=ugarcg.resid,distribution="t",df=4.797230)
par(mfrow=c(2,2))
ts.plot(residuals(fit.btc1), main = "Residuals")
ts.plot(ts(fit.btc1@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.btc1)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.btc1)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.btc1@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.btc1@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.btc1@fit$z,distribution="t",df=tail(fit.btc1@fit$coef,1))
## [1] 1204 707
par(mfrow=c(2,2))
ts.plot(residuals(fit.bnb), main = "Residuals")
ts.plot(ts(fit.bnb@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.bnb)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.bnb)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.bnb@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.bnb@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.bnb@fit$z,distribution="t",df=tail(fit.bnb@fit$coef,1))
## [1] 317 856
par(mfrow=c(2,2))
ts.plot(residuals(fit.bnb1), main = "Residuals")
ts.plot(ts(fit.bnb1@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.bnb1)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.bnb1)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.bnb1@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.bnb1@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.bnb1@fit$z,distribution="t",df=tail(fit.bnb1@fit$coef,1))
## [1] 317 856
par(mfrow=c(2,2))
ts.plot(residuals(fit.eth), main = "Residuals")
ts.plot(ts(fit.eth@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.eth)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.eth)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.eth@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.eth@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.eth@fit$z,distribution="t",df=tail(fit.eth@fit$coef,1))
## [1] 1221 181
par(mfrow=c(2,2))
ts.plot(residuals(fit.eth1), main = "Residuals")
ts.plot(ts(fit.eth1@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.eth1)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.eth1)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.eth1@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.eth1@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.eth1@fit$z,distribution="t",df=tail(fit.eth1@fit$coef,1))
## [1] 1221 181
par(mfrow=c(2,2))
ts.plot(residuals(fit.xrp), main = "Residuals")
ts.plot(ts(fit.xrp@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.xrp)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.xrp)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.xrp@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.xrp@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.xrp@fit$z,distribution="t",df=tail(fit.xrp@fit$coef,1))
## [1] 1102 208
par(mfrow=c(2,2))
ts.plot(residuals(fit.xrp1), main = "Residuals")
ts.plot(ts(fit.xrp1@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.xrp1)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.xrp1)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.xrp1@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.xrp1@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.xrp1@fit$z,distribution="t",df=tail(fit.xrp1@fit$coef,1))
## [1] 1102 208
par(mfrow=c(2,2))
ts.plot(residuals(fit.doge), main = "Residuals")
ts.plot(ts(fit.doge@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.doge)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.doge)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.doge@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.doge@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.doge@fit$z,distribution="t",df=tail(fit.doge@fit$coef,1))
## [1] 206 350
par(mfrow=c(2,2))
ts.plot(residuals(fit.doge1), main = "Residuals")
ts.plot(ts(fit.doge1@fit$z), main = "Standardized Residuals")
acf(as.numeric(residuals(fit.doge1)), main = "ACF of residuals")
acf(as.numeric(residuals(fit.doge1)^2), main = "ACF of squared residuals")
acf(as.numeric(fit.doge1@fit$z), main = "ACF of Standardized residuals")
acf(as.numeric(fit.doge1@fit$z^2), main = "ACF of Standardized squared residuals")
qqPlot(x=fit.doge1@fit$z,distribution="t",df=tail(fit.doge1@fit$coef,1))
## [1] 206 350
*** ARMA-GARCH nahead prediction ***
nfore <- length(data.test[,1])
l <- length(btc.ts)
fore.btc = ugarchforecast(fit.btc,n.ahead=14,ci=0.95)
fore.bnb = ugarchforecast(fit.bnb,n.ahead=14,ci=0.95)
fore.eth = ugarchforecast(fit.eth,n.ahead=14,ci=0.95)
fore.xrp = ugarchforecast(fit.xrp,n.ahead=14,ci=0.95)
fore.doge = ugarchforecast(fit.doge,n.ahead=14,ci=0.95)
armagarch.cnt.btc = fore.btc@forecast$seriesFor[1:14]
armagarch.cnt.btc.ts = ts(armagarch.cnt.btc,start=1)
lo.armagarch.cnt.btc = ts(armagarch.cnt.btc-1.96*fore.btc@forecast$sigmaFor,start=1)
up.armagarch.cnt.btc = ts(armagarch.cnt.btc+1.96*fore.btc@forecast$sigmaFor,start=1)
armagarch.cnt.bnb = fore.bnb@forecast$seriesFor[1:14]
armagarch.cnt.bnb.ts = ts(armagarch.cnt.bnb,start=1)
lo.armagarch.cnt.bnb = ts(armagarch.cnt.bnb-1.96*fore.bnb@forecast$sigmaFor,start=1)
up.armagarch.cnt.bnb = ts(armagarch.cnt.bnb+1.96*fore.bnb@forecast$sigmaFor,start=1)
armagarch.cnt.eth = fore.eth@forecast$seriesFor[1:14]
armagarch.cnt.eth.ts = ts(armagarch.cnt.eth,start=1)
lo.armagarch.cnt.eth = ts(armagarch.cnt.eth-1.96*fore.eth@forecast$sigmaFor,start=1)
up.armagarch.cnt.eth = ts(armagarch.cnt.eth+1.96*fore.eth@forecast$sigmaFor,start=1)
armagarch.cnt.xrp = fore.xrp@forecast$seriesFor[1:14]
armagarch.cnt.xrp.ts = ts(armagarch.cnt.xrp,start=1)
lo.armagarch.cnt.xrp = ts(armagarch.cnt.xrp-1.96*fore.xrp@forecast$sigmaFor,start=1)
up.armagarch.cnt.xrp = ts(armagarch.cnt.xrp+1.96*fore.xrp@forecast$sigmaFor,start=1)
armagarch.cnt.doge = fore.doge@forecast$seriesFor[1:14]
armagarch.cnt.doge.ts = ts(armagarch.cnt.doge,start=1)
lo.armagarch.cnt.doge = ts(armagarch.cnt.doge-1.96*fore.doge@forecast$sigmaFor,start=1)
up.armagarch.cnt.doge = ts(armagarch.cnt.doge+1.96*fore.doge@forecast$sigmaFor,start=1)
layout(mat = matrix(c(1,1,2,2,3,3,
0,4,4,5,5,0), nrow = 2, byrow = TRUE))
ymin=min(btc.ts.test,armagarch.cnt.btc.ts,lo.armagarch.cnt.btc,up.armagarch.cnt.btc)
ymax=max(btc.ts.test,armagarch.cnt.btc.ts,lo.armagarch.cnt.btc,up.armagarch.cnt.btc)
plot(ts(btc.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BTC ARMA-GARCH Predictions")
points(armagarch.cnt.btc.ts,lwd=2,col=btc.col)
lines(lo.armagarch.cnt.btc,lty=3,lwd= 2, col=btc.col)
lines(up.armagarch.cnt.btc,lty=3,lwd= 2, col=btc.col)
ymin=min(bnb.ts.test,armagarch.cnt.bnb.ts,lo.armagarch.cnt.bnb,up.armagarch.cnt.bnb)
ymax=max(bnb.ts.test,armagarch.cnt.bnb.ts,lo.armagarch.cnt.bnb,up.armagarch.cnt.bnb)
plot(ts(bnb.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BNB ARMA-GARCH Predictions")
points(armagarch.cnt.bnb.ts,lwd=2,col=bnb.col)
lines(lo.armagarch.cnt.bnb,lty=3,lwd= 2, col=bnb.col)
lines(up.armagarch.cnt.bnb,lty=3,lwd= 2, col=bnb.col)
ymin=min(eth.ts.test,armagarch.cnt.eth.ts,lo.armagarch.cnt.eth,up.armagarch.cnt.eth)
ymax=max(eth.ts.test,armagarch.cnt.eth.ts,lo.armagarch.cnt.eth,up.armagarch.cnt.eth)
plot(ts(eth.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="ETH ARMA-GARCH Predictions")
points(armagarch.cnt.eth.ts,lwd=2,col=eth.col)
lines(lo.armagarch.cnt.eth,lty=3,lwd= 2, col=eth.col)
lines(up.armagarch.cnt.eth,lty=3,lwd= 2, col=eth.col)
ymin=min(xrp.ts.test,armagarch.cnt.xrp.ts,lo.armagarch.cnt.xrp,up.armagarch.cnt.xrp)
ymax=max(xrp.ts.test,armagarch.cnt.xrp.ts,lo.armagarch.cnt.xrp,up.armagarch.cnt.xrp)
plot(ts(xrp.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="XRP ARMA-GARCH Predictions")
points(armagarch.cnt.xrp.ts,lwd=2,col=xrp.col)
lines(lo.armagarch.cnt.xrp,lty=3,lwd= 2, col=xrp.col)
lines(up.armagarch.cnt.xrp,lty=3,lwd= 2, col=xrp.col)
ymin=min(doge.ts.test,armagarch.cnt.doge.ts,lo.armagarch.cnt.doge,up.armagarch.cnt.doge)
ymax=max(doge.ts.test,armagarch.cnt.doge.ts,lo.armagarch.cnt.doge,up.armagarch.cnt.doge)
plot(ts(doge.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="DOGE ARMA-GARCH Predictions")
points(armagarch.cnt.doge.ts,lwd=2,col=doge.col)
lines(lo.armagarch.cnt.doge,lty=3,lwd= 2, col=doge.col)
lines(up.armagarch.cnt.doge,lty=3,lwd= 2, col=doge.col)
cat("BTC ARMA-GARCH MAE:",mean(abs(armagarch.cnt.btc-btc.ts.test)),"\nBTC ARMA-GARCH PM:",
sum((armagarch.cnt.btc-btc.ts.test)^2)/sum((btc.ts.test-mean(btc.ts.test))^2))
## BTC ARMA-GARCH MAE: 0.04363519
## BTC ARMA-GARCH PM: 8.046493
cat("BNB ARMA-GARCH MAE:",mean(abs(armagarch.cnt.bnb-bnb.ts.test)),"\nBNB ARMA-GARCH PM:",
sum((armagarch.cnt.bnb-bnb.ts.test)^2)/sum((bnb.ts.test-mean(bnb.ts.test))^2))
## BNB ARMA-GARCH MAE: 0.03501485
## BNB ARMA-GARCH PM: 1.189507
cat("ETH ARMA-GARCH MAE:",mean(abs(armagarch.cnt.eth-eth.ts.test)),"\nETH ARMA GARCH PM:",
sum((armagarch.cnt.eth-eth.ts.test)^2)/sum((eth.ts.test-mean(eth.ts.test))^2))
## ETH ARMA-GARCH MAE: 0.02776655
## ETH ARMA GARCH PM: 1.686322
cat("XRP ARMA-GARCH MAE:",mean(abs(armagarch.cnt.xrp-xrp.ts.test)),"\nXRP ARMA-GARCH PM:",
sum((armagarch.cnt.xrp-xrp.ts.test)^2)/sum((xrp.ts.test-mean(xrp.ts.test))^2))
## XRP ARMA-GARCH MAE: 0.02538409
## XRP ARMA-GARCH PM: 1.759778
cat("DOGE ARMA-GARCH MAE:",mean(abs(armagarch.cnt.doge-doge.ts.test)),"\nDOGE ARMA-GARCH PM:",
sum((armagarch.cnt.doge-doge.ts.test)^2)/sum((doge.ts.test-mean(doge.ts.test))^2))
## DOGE ARMA-GARCH MAE: 0.08364447
## DOGE ARMA-GARCH PM: 5.730931
*** ARIMA-GARCH nahead predictions ***
nfore <- length(data.test[,1])
l <- length(btc.ts)
fore.btc = ugarchforecast(fit.btc1,n.ahead=14,ci=0.95)
fore.bnb = ugarchforecast(fit.bnb1,n.ahead=14,ci=0.95)
fore.eth = ugarchforecast(fit.eth1,n.ahead=14,ci=0.95)
fore.xrp = ugarchforecast(fit.xrp1,n.ahead=14,ci=0.95)
fore.doge = ugarchforecast(fit.doge1,n.ahead=14,ci=0.95)
armagarch.cnt.btc = fore.btc@forecast$seriesFor[1:14]
armagarch.cnt.btc.ts = ts(armagarch.cnt.btc,start=1)
lo.armagarch.cnt.btc = ts(armagarch.cnt.btc-1.96*fore.btc@forecast$sigmaFor,start=1)
up.armagarch.cnt.btc = ts(armagarch.cnt.btc+1.96*fore.btc@forecast$sigmaFor,start=1)
armagarch.cnt.bnb = fore.bnb@forecast$seriesFor[1:14]
armagarch.cnt.bnb.ts = ts(armagarch.cnt.bnb,start=1)
lo.armagarch.cnt.bnb = ts(armagarch.cnt.bnb-1.96*fore.bnb@forecast$sigmaFor,start=1)
up.armagarch.cnt.bnb = ts(armagarch.cnt.bnb+1.96*fore.bnb@forecast$sigmaFor,start=1)
armagarch.cnt.eth = fore.eth@forecast$seriesFor[1:14]
armagarch.cnt.eth.ts = ts(armagarch.cnt.eth,start=1)
lo.armagarch.cnt.eth = ts(armagarch.cnt.eth-1.96*fore.eth@forecast$sigmaFor,start=1)
up.armagarch.cnt.eth = ts(armagarch.cnt.eth+1.96*fore.eth@forecast$sigmaFor,start=1)
armagarch.cnt.xrp = fore.xrp@forecast$seriesFor[1:14]
armagarch.cnt.xrp.ts = ts(armagarch.cnt.xrp,start=1)
lo.armagarch.cnt.xrp = ts(armagarch.cnt.xrp-1.96*fore.xrp@forecast$sigmaFor,start=1)
up.armagarch.cnt.xrp = ts(armagarch.cnt.xrp+1.96*fore.xrp@forecast$sigmaFor,start=1)
armagarch.cnt.doge = fore.doge@forecast$seriesFor[1:14]
armagarch.cnt.doge.ts = ts(armagarch.cnt.doge,start=1)
lo.armagarch.cnt.doge = ts(armagarch.cnt.doge-1.96*fore.doge@forecast$sigmaFor,start=1)
up.armagarch.cnt.doge = ts(armagarch.cnt.doge+1.96*fore.doge@forecast$sigmaFor,start=1)
layout(mat = matrix(c(1,1,2,2,3,3,
0,4,4,5,5,0), nrow = 2, byrow = TRUE))
ymin=min(btc.ts.test,armagarch.cnt.btc.ts,lo.armagarch.cnt.btc,up.armagarch.cnt.btc)
ymax=max(btc.ts.test,armagarch.cnt.btc.ts,lo.armagarch.cnt.btc,up.armagarch.cnt.btc)
plot(ts(btc.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BTC ARIMA-GARCH Predictions")
points(armagarch.cnt.btc.ts,lwd=2,col=btc.col)
lines(lo.armagarch.cnt.btc,lty=3,lwd= 2, col=btc.col)
lines(up.armagarch.cnt.btc,lty=3,lwd= 2, col=btc.col)
ymin=min(bnb.ts.test,armagarch.cnt.bnb.ts,lo.armagarch.cnt.bnb,up.armagarch.cnt.bnb)
ymax=max(bnb.ts.test,armagarch.cnt.bnb.ts,lo.armagarch.cnt.bnb,up.armagarch.cnt.bnb)
plot(ts(bnb.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BNB ARIMA-GARCH Predictions")
points(armagarch.cnt.bnb.ts,lwd=2,col=bnb.col)
lines(lo.armagarch.cnt.bnb,lty=3,lwd= 2, col=bnb.col)
lines(up.armagarch.cnt.bnb,lty=3,lwd= 2, col=bnb.col)
ymin=min(eth.ts.test,armagarch.cnt.eth.ts,lo.armagarch.cnt.eth,up.armagarch.cnt.eth)
ymax=max(eth.ts.test,armagarch.cnt.eth.ts,lo.armagarch.cnt.eth,up.armagarch.cnt.eth)
plot(ts(eth.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="ETH ARIMA-GARCH Predictions")
points(armagarch.cnt.eth.ts,lwd=2,col=eth.col)
lines(lo.armagarch.cnt.eth,lty=3,lwd= 2, col=eth.col)
lines(up.armagarch.cnt.eth,lty=3,lwd= 2, col=eth.col)
ymin=min(xrp.ts.test,armagarch.cnt.xrp.ts,lo.armagarch.cnt.xrp,up.armagarch.cnt.xrp)
ymax=max(xrp.ts.test,armagarch.cnt.xrp.ts,lo.armagarch.cnt.xrp,up.armagarch.cnt.xrp)
plot(ts(xrp.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="XRP ARIMA-GARCH Predictions")
points(armagarch.cnt.xrp.ts,lwd=2,col=xrp.col)
lines(lo.armagarch.cnt.xrp,lty=3,lwd= 2, col=xrp.col)
lines(up.armagarch.cnt.xrp,lty=3,lwd= 2, col=xrp.col)
ymin=min(doge.ts.test,armagarch.cnt.doge.ts,lo.armagarch.cnt.doge,up.armagarch.cnt.doge)
ymax=max(doge.ts.test,armagarch.cnt.doge.ts,lo.armagarch.cnt.doge,up.armagarch.cnt.doge)
plot(ts(doge.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="DOGE ARIMA-GARCH Predictions")
points(armagarch.cnt.doge.ts,lwd=2,col=doge.col)
lines(lo.armagarch.cnt.doge,lty=3,lwd= 2, col=doge.col)
lines(up.armagarch.cnt.doge,lty=3,lwd= 2, col=doge.col)
cat("BTC ARIMA GARCH MAE:",mean(abs(armagarch.cnt.btc-btc.ts.test)),"\nBTC ARIMA GARCH PM:",
sum((armagarch.cnt.btc-btc.ts.test)^2)/sum((btc.ts.test-mean(btc.ts.test))^2))
## BTC ARIMA GARCH MAE: 0.04066313
## BTC ARIMA GARCH PM: 7.041747
cat("BNB ARIMA GARCH MAE:",mean(abs(armagarch.cnt.bnb-bnb.ts.test)),"\nBNB ARIMA GARCH PM:",
sum((armagarch.cnt.bnb-bnb.ts.test)^2)/sum((bnb.ts.test-mean(bnb.ts.test))^2))
## BNB ARIMA GARCH MAE: 0.03465104
## BNB ARIMA GARCH PM: 1.162675
cat("ETH ARIMA GARCH MAE:",mean(abs(armagarch.cnt.eth-eth.ts.test)),"\nETH ARIMA GARCH PM:",
sum((armagarch.cnt.eth-eth.ts.test)^2)/sum((eth.ts.test-mean(eth.ts.test))^2))
## ETH ARIMA GARCH MAE: 0.02683635
## ETH ARIMA GARCH PM: 1.595674
cat("XRP ARIMA GARCH MAE:",mean(abs(armagarch.cnt.xrp-xrp.ts.test)),"\nXRP ARIMA GARCH PM:",
sum((armagarch.cnt.xrp-xrp.ts.test)^2)/sum((xrp.ts.test-mean(xrp.ts.test))^2))
## XRP ARIMA GARCH MAE: 0.0203954
## XRP ARIMA GARCH PM: 1.314208
cat("DOGE ARIMA GARCH MAE:",mean(abs(armagarch.cnt.doge-doge.ts.test)),"\nDOGE ARIMA GARCH PM:",
sum((armagarch.cnt.doge-doge.ts.test)^2)/sum((doge.ts.test-mean(doge.ts.test))^2))
## DOGE ARIMA GARCH MAE: 0.07968189
## DOGE ARIMA GARCH PM: 5.269887
*** ARMA-GARCH rolling predictions ***
fore.series.btc = NULL
fore.se.btc = NULL
fore.series.bnb = NULL
fore.se.bnb = NULL
fore.series.eth = NULL
fore.se.eth = NULL
fore.series.xrp = NULL
fore.se.xrp = NULL
fore.series.doge = NULL
fore.se.doge = NULL
for(f in 1: 14){
## Fit models
data.btc = btc.ts.train
data.bnb = bnb.ts.train
data.eth = eth.ts.train
data.xrp = xrp.ts.train
data.doge = doge.ts.train
if(f>=2){
data.btc = c(btc.ts.train,btc.ts.test[1:(f-1)])
data.bnb = c(bnb.ts.train,bnb.ts.test[1:(f-1)])
data.eth = c(eth.ts.train,eth.ts.test[1:(f-1)])
data.xrp = c(xrp.ts.train,xrp.ts.test[1:(f-1)])
data.doge = c(doge.ts.train,doge.ts.test[1:(f-1)])
}
mod.btc1=ugarchfit(spec.btc, data.btc, solver = 'hybrid')
mod.bnb1=ugarchfit(spec.bnb, data.bnb, solver = 'hybrid')
mod.eth1=ugarchfit(spec.eth, data.eth, solver = 'hybrid')
mod.xrp1=ugarchfit(spec.xrp, data.xrp, solver = 'hybrid')
mod.doge1=ugarchfit(spec.doge, data.doge, solver = 'hybrid')
## Forecast
fore.btc = ugarchforecast(mod.btc1,n.ahead=1,ci=0.95)
fore.series.btc = c(fore.series.btc, fore.btc@forecast$seriesFor)
fore.se.btc = c(fore.se.btc, fore.btc@forecast$sigmaFor)
fore.bnb = ugarchforecast(mod.bnb1,n.ahead=1,ci=0.95)
fore.series.bnb = c(fore.series.bnb, fore.bnb@forecast$seriesFor)
fore.se.bnb = c(fore.se.bnb, fore.bnb@forecast$sigmaFor)
fore.eth = ugarchforecast(mod.eth1,n.ahead=1,ci=0.95)
fore.series.eth = c(fore.series.eth, fore.eth@forecast$seriesFor)
fore.se.eth = c(fore.se.eth, fore.eth@forecast$sigmaFor)
fore.xrp = ugarchforecast(mod.xrp1,n.ahead=1,ci=0.95)
fore.series.xrp = c(fore.series.xrp, fore.xrp@forecast$seriesFor)
fore.se.xrp = c(fore.se.xrp, fore.xrp@forecast$sigmaFor)
fore.doge = ugarchforecast(mod.doge1,n.ahead=1,ci=0.95)
fore.series.doge = c(fore.series.doge, fore.doge@forecast$seriesFor)
fore.se.doge = c(fore.se.doge, fore.doge@forecast$sigmaFor)
}
layout(mat = matrix(c(1,1,2,2,3,3,
0,4,4,5,5,0), nrow = 2, byrow = TRUE))
fore.series.btc=ts(fore.series.btc,start=1)
lbound = ts(fore.series.btc-1.96*fore.se.btc,start=1)
ubound = ts(fore.series.btc+1.96*fore.se.btc,start=1)
ymin=min(btc.ts.test,fore.series.btc,lbound,ubound)
ymax=max(btc.ts.test,fore.series.btc,lbound,ubound)
plot(ts(btc.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BTC ARMA-GARCH Predictions")
points(fore.series.btc,lwd=2,col=btc.col)
lines(lbound,lty=3,lwd= 2, col=btc.col)
lines(ubound,lty=3,lwd= 2, col=btc.col)
fore.series.bnb=ts(fore.series.bnb,start=1)
lbound = ts(fore.series.bnb-1.96*fore.se.bnb,start=1)
ubound = ts(fore.series.bnb+1.96*fore.se.bnb,start=1)
ymin=min(bnb.ts.test,fore.series.bnb,lbound,ubound)
ymax=max(bnb.ts.test,fore.series.bnb,lbound,ubound)
plot(ts(bnb.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BNB ARMA-GARCH Predictions")
points(fore.series.bnb,lwd=2,col=bnb.col)
lines(lbound,lty=3,lwd= 2, col=bnb.col)
lines(ubound,lty=3,lwd= 2, col=bnb.col)
fore.series.eth=ts(fore.series.eth,start=1)
lbound = ts(fore.series.eth-1.96*fore.se.eth,start=1)
ubound = ts(fore.series.eth+1.96*fore.se.eth,start=1)
ymin=min(eth.ts.test,fore.series.eth,lbound,ubound)
ymax=max(eth.ts.test,fore.series.eth,lbound,ubound)
plot(ts(eth.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="ETH ARMA-GARCH Predictions")
points(fore.series.eth,lwd=2,col=eth.col)
lines(lbound,lty=3,lwd= 2, col=eth.col)
lines(ubound,lty=3,lwd= 2, col=eth.col)
fore.series.xrp=ts(fore.series.xrp,start=1)
lbound = ts(fore.series.xrp-1.96*fore.se.xrp,start=1)
ubound = ts(fore.series.xrp+1.96*fore.se.xrp,start=1)
ymin=min(xrp.ts.test,fore.series.xrp,lbound,ubound)
ymax=max(xrp.ts.test,fore.series.xrp,lbound,ubound)
plot(ts(xrp.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="XRP ARMA-GARCH Predictions")
points(fore.series.xrp,lwd=2,col=xrp.col)
lines(lbound,lty=3,lwd= 2, col=xrp.col)
lines(ubound,lty=3,lwd= 2, col=xrp.col)
fore.series.doge=ts(fore.series.doge,start=1)
lbound = ts(fore.series.doge-1.96*fore.se.doge,start=1)
ubound = ts(fore.series.doge+1.96*fore.se.doge,start=1)
ymin=min(doge.ts.test,fore.series.doge,lbound,ubound)
ymax=max(doge.ts.test,fore.series.doge,lbound,ubound)
plot(ts(doge.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="DOGE ARMA-GARCH Predictions")
points(fore.series.doge,lwd=2,col=doge.col)
lines(lbound,lty=3,lwd= 2, col=doge.col)
lines(ubound,lty=3,lwd= 2, col=doge.col)
cat("BTC ARMA-GARCH MAE:",mean(abs(fore.series.btc-btc.ts.test)),"\nBTC ARMA-GARCH PM:",
sum((fore.series.btc-btc.ts.test)^2)/sum((btc.ts.test-mean(btc.ts.test))^2))
## BTC ARMA-GARCH MAE: 0.0189666
## BTC ARMA-GARCH PM: 2.80284
cat("BNB ARMA-GARCH MAE:",mean(abs(fore.series.bnb-bnb.ts.test)),"\nBNB ARMA-GARCH PM:",
sum((fore.series.bnb-bnb.ts.test)^2)/sum((bnb.ts.test-mean(bnb.ts.test))^2))
## BNB ARMA-GARCH MAE: 0.0233654
## BNB ARMA-GARCH PM: 0.9904282
cat("ETH ARMA-GARCH MAE:",mean(abs(fore.series.eth-eth.ts.test)),"\nETH ARMA-GARCH PM:",
sum((fore.series.eth-eth.ts.test)^2)/sum((eth.ts.test-mean(eth.ts.test))^2))
## ETH ARMA-GARCH MAE: 0.0191366
## ETH ARMA-GARCH PM: 1.316564
cat("XRP ARMA-GARCH MAE:",mean(abs(fore.series.xrp-xrp.ts.test)),"\nXRP ARMA-GARCH PM:",
sum((fore.series.xrp-xrp.ts.test)^2)/sum((xrp.ts.test-mean(xrp.ts.test))^2))
## XRP ARMA-GARCH MAE: 0.02127096
## XRP ARMA-GARCH PM: 1.436835
cat("DOGE ARMA-GARCH MAE:",mean(abs(fore.series.doge-doge.ts.test)),"\nDOGE ARMA-GARCH PM:",
sum((fore.series.doge-doge.ts.test)^2)/sum((doge.ts.test-mean(doge.ts.test))^2))
## DOGE ARMA-GARCH MAE: 0.03365305
## DOGE ARMA-GARCH PM: 1.305538
*** ARIMA-GARCH Rolling predictions ***
fore.series.btc = NULL
fore.se.btc = NULL
fore.series.bnb = NULL
fore.se.bnb = NULL
fore.series.eth = NULL
fore.se.eth = NULL
fore.series.xrp = NULL
fore.se.xrp = NULL
fore.series.doge = NULL
fore.se.doge = NULL
for(f in 1: 14){
## Fit models
data.btc = btc.ts.train
data.bnb = bnb.ts.train
data.eth = eth.ts.train
data.xrp = xrp.ts.train
data.doge = doge.ts.train
if(f>=2){
data.btc = c(btc.ts.train,btc.ts.test[1:(f-1)])
data.bnb = c(bnb.ts.train,bnb.ts.test[1:(f-1)])
data.eth = c(eth.ts.train,eth.ts.test[1:(f-1)])
data.xrp = c(xrp.ts.train,xrp.ts.test[1:(f-1)])
data.doge = c(doge.ts.train,doge.ts.test[1:(f-1)])
}
mod.btc1=ugarchfit(spec.btc1, data.btc, solver = 'hybrid')
mod.bnb1=ugarchfit(spec.bnb1, data.bnb, solver = 'hybrid')
mod.eth1=ugarchfit(spec.eth1, data.eth, solver = 'hybrid')
mod.xrp1=ugarchfit(spec.xrp1, data.xrp, solver = 'hybrid')
mod.doge1=ugarchfit(spec.doge1, data.doge, solver = 'hybrid')
## Forecast
fore.btc = ugarchforecast(mod.btc1,n.ahead=1,ci=0.95)
fore.series.btc = c(fore.series.btc, fore.btc@forecast$seriesFor)
fore.se.btc = c(fore.se.btc, fore.btc@forecast$sigmaFor)
fore.bnb = ugarchforecast(mod.bnb1,n.ahead=1,ci=0.95)
fore.series.bnb = c(fore.series.bnb, fore.bnb@forecast$seriesFor)
fore.se.bnb = c(fore.se.bnb, fore.bnb@forecast$sigmaFor)
fore.eth = ugarchforecast(mod.eth1,n.ahead=1,ci=0.95)
fore.series.eth = c(fore.series.eth, fore.eth@forecast$seriesFor)
fore.se.eth = c(fore.se.eth, fore.eth@forecast$sigmaFor)
fore.xrp = ugarchforecast(mod.xrp1,n.ahead=1,ci=0.95)
fore.series.xrp = c(fore.series.xrp, fore.xrp@forecast$seriesFor)
fore.se.xrp = c(fore.se.xrp, fore.xrp@forecast$sigmaFor)
fore.doge = ugarchforecast(mod.doge1,n.ahead=1,ci=0.95)
fore.series.doge = c(fore.series.doge, fore.doge@forecast$seriesFor)
fore.se.doge = c(fore.se.doge, fore.doge@forecast$sigmaFor)
}
layout(mat = matrix(c(1,1,2,2,3,3,
0,4,4,5,5,0), nrow = 2, byrow = TRUE))
fore.series.btc=ts(fore.series.btc,start=1)
lbound = ts(fore.series.btc-1.96*fore.se.btc,start=1)
ubound = ts(fore.series.btc+1.96*fore.se.btc,start=1)
ymin=min(btc.ts.test,fore.series.btc,lbound,ubound)
ymax=max(btc.ts.test,fore.series.btc,lbound,ubound)
plot(ts(btc.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BTC ARIMA-GARCH Predictions")
points(fore.series.btc,lwd=2,col=btc.col)
lines(lbound,lty=3,lwd= 2, col=btc.col)
lines(ubound,lty=3,lwd= 2, col=btc.col)
fore.series.bnb=ts(fore.series.bnb,start=1)
lbound = ts(fore.series.bnb-1.96*fore.se.bnb,start=1)
ubound = ts(fore.series.bnb+1.96*fore.se.bnb,start=1)
ymin=min(bnb.ts.test,fore.series.bnb,lbound,ubound)
ymax=max(bnb.ts.test,fore.series.bnb,lbound,ubound)
plot(ts(bnb.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="BNB ARIMA-GARCH Predictions")
points(fore.series.bnb,lwd=2,col=bnb.col)
lines(lbound,lty=3,lwd= 2, col=bnb.col)
lines(ubound,lty=3,lwd= 2, col=bnb.col)
fore.series.eth=ts(fore.series.eth,start=1)
lbound = ts(fore.series.eth-1.96*fore.se.eth,start=1)
ubound = ts(fore.series.eth+1.96*fore.se.eth,start=1)
ymin=min(eth.ts.test,fore.series.eth,lbound,ubound)
ymax=max(eth.ts.test,fore.series.eth,lbound,ubound)
plot(ts(eth.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="ETH ARIMA-GARCH Predictions")
points(fore.series.eth,lwd=2,col=eth.col)
lines(lbound,lty=3,lwd= 2, col=eth.col)
lines(ubound,lty=3,lwd= 2, col=eth.col)
fore.series.xrp=ts(fore.series.xrp,start=1)
lbound = ts(fore.series.xrp-1.96*fore.se.xrp,start=1)
ubound = ts(fore.series.xrp+1.96*fore.se.xrp,start=1)
ymin=min(xrp.ts.test,fore.series.xrp,lbound,ubound)
ymax=max(xrp.ts.test,fore.series.xrp,lbound,ubound)
plot(ts(xrp.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="XRP ARIMA-GARCH Predictions")
points(fore.series.xrp,lwd=2,col=xrp.col)
lines(lbound,lty=3,lwd= 2, col=xrp.col)
lines(ubound,lty=3,lwd= 2, col=xrp.col)
fore.series.doge=ts(fore.series.doge,start=1)
lbound = ts(fore.series.doge-1.96*fore.se.doge,start=1)
ubound = ts(fore.series.doge+1.96*fore.se.doge,start=1)
ymin=min(doge.ts.test,fore.series.doge,lbound,ubound)
ymax=max(doge.ts.test,fore.series.doge,lbound,ubound)
plot(ts(doge.ts.test,start=1), ylim=c(ymin,ymax), ylab="Log Price", type="l",main="DOGE ARIMA-GARCH Predictions")
points(fore.series.doge,lwd=2,col=doge.col)
lines(lbound,lty=3,lwd= 2, col=doge.col)
lines(ubound,lty=3,lwd= 2, col=doge.col)
cat("BTC ARIMA-GARCH MAE:",mean(abs(fore.series.btc-btc.ts.test)),"\nBTC ARIMA-GARCH PM:",
sum((fore.series.btc-btc.ts.test)^2)/sum((btc.ts.test-mean(btc.ts.test))^2))
## BTC ARIMA-GARCH MAE: 0.01947751
## BTC ARIMA-GARCH PM: 2.948654
cat("BNB ARIMA-GARCH MAE:",mean(abs(fore.series.bnb-bnb.ts.test)),"\nBNB ARIMA-GARCH PM:",
sum((fore.series.bnb-bnb.ts.test)^2)/sum((bnb.ts.test-mean(bnb.ts.test))^2))
## BNB ARIMA-GARCH MAE: 0.02526373
## BNB ARIMA-GARCH PM: 1.095287
cat("ETH ARIMA-GARCH MAE:",mean(abs(fore.series.eth-eth.ts.test)),"\nETH ARIMA-GARCH PM:",
sum((fore.series.eth-eth.ts.test)^2)/sum((eth.ts.test-mean(eth.ts.test))^2))
## ETH ARIMA-GARCH MAE: 0.01910137
## ETH ARIMA-GARCH PM: 1.402026
cat("XRP ARIMA-GARCH MAE:",mean(abs(fore.series.xrp-xrp.ts.test)),"\nXRP ARIMA-GARCH PM:",
sum((fore.series.xrp-xrp.ts.test)^2)/sum((xrp.ts.test-mean(xrp.ts.test))^2))
## XRP ARIMA-GARCH MAE: 0.02233451
## XRP ARIMA-GARCH PM: 1.601399
cat("DOGE ARIMA-GARCH MAE:",mean(abs(fore.series.doge-doge.ts.test)),"\nDOGE ARIMA-GARCH PM:",
sum((fore.series.doge-doge.ts.test)^2)/sum((doge.ts.test-mean(doge.ts.test))^2))
## DOGE ARIMA-GARCH MAE: 0.03324621
## DOGE ARIMA-GARCH PM: 1.308724